Skip to content

Conversation

LeorentKelmendi
Copy link

Based on parse-url plugin:

Note that when url-parse is used in a browser environment, it will default to using the browser's current window location as the base URL when parsing all inputs. To parse an input independently of the browser's current URL (e.g. for functionality parity with the library in a Node environment), pass an empty location object as the second parameter:

var parse = require('url-parse');
parse('hostname', {});

when i tried to use the plugin with gatsby SSR failed due to url not being string as it could not extract window info causing Cannot read property 'split' of null to crash whole SSR.

passing second argument as {} solved the issue in SSR.

parse url independent of browser window to avoid crash in SSR, as current plugin breaks SSR due to default `window` use from `Url` parser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant